package com.siqi.hr.system.custom.entity;

import com.siqi.hr.system.organization.entity.Employee;
import org.springframework.jdbc.core.RowMapper;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * 系统定制查询对象
 * @author    xiaogq
 * Created by xiaogoingqin on 2016/7/24.
 */
public class Query  implements Serializable {

    private static final long serialVersionUID = -2970341437527237638L;

    /**
     * 主键id
     */
    private int id;

    /**
     * 查询条件名称
     */
    private String name;

    /**
     * 创建时间
     */
    private Date createDate;

    /**
     * 所属员工
     */
    private Employee employee;

    /**
     * 所属实体
     */
    private EntityRecord entity;

    /**
     * 排序
     */
    private int position;

    /**
     * 是否在列表上显示(0:否，1:是默认值为1)
     */
    private Boolean listShow;

    /**
     * 查询条件是否公开(0:否，1:是默认值为0)
     */
    private Boolean publicShow;

    /**
     * 是否是系统查询条件(0:否，1:是默认值为0，系统查询条件不能删除)
     */
    private Boolean isSystem;

    /**
     * 查询条件值以json数据格式存储
     */
    private String extparam;

    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreateDate() {
        return this.createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Employee getEmployee() {
        return this.employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    public EntityRecord getEntity() {
        return this.entity;
    }

    public void setEntity(EntityRecord entity) {
        this.entity = entity;
    }

    public int getPosition() {
        return this.position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public Boolean getListShow() {
        return this.listShow;
    }

    public void setListShow(Boolean listShow) {
        this.listShow = listShow;
    }

    public Boolean getPublicShow() {
        return this.publicShow;
    }

    public void setPublicShow(Boolean publicShow) {
        this.publicShow = publicShow;
    }

    public Boolean getIsSystem() {
        return this.isSystem;
    }

    public void setIsSystem(Boolean isSystem) {
        this.isSystem = isSystem;
    }

    public String getExtparam() {
        return this.extparam;
    }

    public void setExtparam(String extparam) {
        this.extparam = extparam;
    }

    public Query() {
    }

    public Query(int id) {
        this.id = id;
    }

    public Query(int id, String name, String extparam) {
        this.id = id;
        this.name = name;
        this.extparam = extparam;
    }

    @Override
    public int hashCode() {
        int result = 1;
        result = 31 * result + this.id;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Query other = (Query) obj;
        if (this.id != other.id)
            return false;
        return true;
    }

    public static class MainField extends Query implements RowMapper<Query> {
        public Query mapRow(ResultSet rs, int index) throws SQLException {
            Query query = new Query();
            query.setId(rs.getInt("id"));
            query.setName(rs.getString("name"));
            query.setExtparam(rs.getString("extparam"));
            return query;
        }
    }

}
